const Streamer = require('./Streamer')
const fs = require("fs");

let videoData;
function loadVideoData(fileName){
    return new Promise(((resolve, reject) => {
        fs.readFile(fileName,'binary',function(err,data){
            if(err){
                console.log(err)
                reject();
            }else{
                resolve(data);
            }
        });
    }))
}

async function main() {
    const myStream = new Streamer();
    videoData = await loadVideoData('media/1.rgb');

    const streamId = 123;
    let config = {
        streamId,
        audioParam:{},
        videoParam:{},
        forwardUrl: "https://www.baidu.com"
    }

    myStream.startStream(config)

    //周期发送视频数据
    setInterval(async()=>{
        myStream.sendVideo(streamId, videoData);
    }, 10);
}

main().then(() => {});